package concept.misc;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class CollectionLab
{
	static void doClearList()
	{
		List<String> list = new ArrayList<String>(3);
		list.add("a");
		list.add("b");
		list.add("c");
		System.out.println(list.size());
		list.clear();
		System.out.println(list.size());
	}
	
	static void doSortedList()
	{
		List<String> aList = new ArrayList<String>();
		aList.add("China");
		aList.add("France");
		aList.add("UK");
		aList.add("Russia");
		aList.add("USA");
		Collections.sort(aList);
		int pos = Collections.binarySearch(aList, "China");
		System.out.println(pos);
	}
	
	static void doUnsortedList()
	{
		List<String> aList = new ArrayList<String>();
		aList.add("France");
		aList.add("UK");
		aList.add("China");
		aList.add("USA");
		aList.add("Russia");
		int pos = Collections.binarySearch(aList, "China");
		System.out.println(pos);
	}
	
	public static void main(String[] args)
	{
		doUnsortedList();
		doSortedList();
	}
}
